﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace System
{
    public static class TryExtension
    {
        /// <summary>
        /// 尝试输出一个非空字符串
        /// </summary>
        /// <param name="Str">可能为空的字符串</param>
        /// <param name="OutString">字符串为空时输出的值</param>
        /// <returns></returns>
        public static String Try(this String Str, String OutString)
        {
            try
            {
                if (String.IsNullOrEmpty(Str))
                {
                    return OutString;
                }
                else
                {
                    return Str;
                }
            }
            catch
            {
                return OutString;
            }
        }
    }

    public static class ConvertExtension
    {
        public static  bool IsInt(this String Str)
        {
            int t = 0;
            return int.TryParse(Str, out t); 
        }

        public static  bool IsDecimal(this String Str)
        { 
            Decimal t = 0;
            return Decimal.TryParse(Str, out t);
        }
    }
}
